package com.gba.mark.user.mapper.permission;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gba.mark.user.entity.permission.Permission;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface PermissionMapper extends BaseMapper<Permission> {

    /**
     * 根据角色获取权限内容
     * @param roleId 角色id
     * @return 资源列表
     */
    @Select("SELECT p.* FROM permission p, role_permission r " +
            "WHERE r.role_id = #{roleId} AND r.permission_id = p.id")
    @Results({
            @Result(property = "parentId",column = "parent_id"),
            @Result(property = "resName",column = "res_name"),
            @Result(property = "resType",column = "res_type"),
    })
    List<Permission> selectPermissionByRoleId(@Param("roleId") long roleId);
}
